<?php

namespace Tests;

use PHPUnit\Framework\TestCase;

class TestHash extends TestCase
{
    public function testHmac()
    {
        $algo = 'md5';
        $data = '待进行散列运算的消息。';
        $key = '123456';
        $str = hash_hmac($algo, $data, $key);
        var_dump($str);
        self::assertIsString($str);
    }

    public function testEquals()
    {
        $algo = 'md5';
        $data = '待进行散列运算的消息。';
        $key = '123456';
        $sign = hash_hmac($algo, $data, $key);
        var_dump($sign);
        $rst = hash_equals('db89311d29908a24c9e1ffa868b7ee37', $sign);
        var_dump($rst);
        self::assertTrue($rst);
    }
}
